package com.ruoyi.cert.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cert.mapper.CertOrganizationMapper;
import com.ruoyi.cert.domain.CertOrganization;
import com.ruoyi.cert.service.ICertOrganizationService;

/**
 * 颁发机构Service业务层处理
 *
 * @author mxh
 * @date 2023-03-26
 */
@Service
public class CertOrganizationServiceImpl implements ICertOrganizationService {
    @Autowired
    private CertOrganizationMapper certOrganizationMapper;

    /**
     * 查询颁发机构
     *
     * @param id 颁发机构主键
     * @return 颁发机构
     */
    @Override
    public CertOrganization selectCertOrganizationById(Long id) {
        return certOrganizationMapper.selectCertOrganizationById(id);
    }

    /**
     * 查询颁发机构列表
     *
     * @param certOrganization 颁发机构
     * @return 颁发机构
     */
    @Override
    public List<CertOrganization> selectCertOrganizationList(CertOrganization certOrganization) {
        return certOrganizationMapper.selectCertOrganizationList(certOrganization);
    }

    /**
     * 新增颁发机构
     *
     * @param certOrganization 颁发机构
     * @return 结果
     */
    @Override
    public int insertCertOrganization(CertOrganization certOrganization) {
        certOrganization.setCreateDate(DateUtils.getNowDate());
        certOrganization.setCreateBy(SecurityUtils.getUsername());
        return certOrganizationMapper.insertCertOrganization(certOrganization);
    }

    /**
     * 修改颁发机构
     *
     * @param certOrganization 颁发机构
     * @return 结果
     */
    @Override
    public int updateCertOrganization(CertOrganization certOrganization) {
        certOrganization.setUpdateDate(DateUtils.getNowDate());
        certOrganization.setUpdateBy(SecurityUtils.getUsername());
        return certOrganizationMapper.updateCertOrganization(certOrganization);
    }

    /**
     * 批量删除颁发机构
     *
     * @param ids 需要删除的颁发机构主键
     * @return 结果
     */
    @Override
    public int deleteCertOrganizationByIds(Long[] ids) {
        return certOrganizationMapper.deleteCertOrganizationByIds(ids);
    }

    /**
     * 删除颁发机构信息
     *
     * @param id 颁发机构主键
     * @return 结果
     */
    @Override
    public int deleteCertOrganizationById(Long id) {
        return certOrganizationMapper.deleteCertOrganizationById(id);
    }
}
